#include "wxsboxsizer.h"

#include <prep.h>

namespace {
  wxsRegisterItem<wxsBoxSizer> Reg( _T( "BoxSizer" ), _T( "BoxSizer" ), wxsTSizer, _T( "布局" ), 90 );
}

wxsBoxSizer::wxsBoxSizer( wxsItemResData* Data ):
  wxsSizer( Data, &Reg.Info ),
  Orient( wxHORIZONTAL ) {
}

wxSizer* wxsBoxSizer::OnBuildSizerPreview( M_Code_unused wxWindow* Parent ) {
  return new wxBoxSizer( Orient );
}

void wxsBoxSizer::OnBuildSizerCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/sizer.h>" ), GetInfo().ClassName, hfInPCH );
      Codef( _T( "%C(%s);\n" ), ( Orient != wxHORIZONTAL ) ? _T( "wxVERTICAL" ) : _T( "wxHORIZONTAL" ) );
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsBoxSizer::OnBuildSizerCreatingCode" ), GetLanguage() );
    }
  }
}

void wxsBoxSizer::OnEnumSizerProperties( M_Code_unused long Flags ) {
  static const long    OrientValues[] = { wxHORIZONTAL, wxVERTICAL, 0 };
  static const wxChar* OrientNames[]  = { _T( "wxHORIZONTAL" ), _T( "wxVERTICAL" ), 0 };
  WXS_ENUM( wxsBoxSizer, Orient, _T( "Orientation" ), _T( "orient" ), OrientValues, OrientNames, wxHORIZONTAL );
}
